﻿CREATE PROCEDURE [dbo].[CourseDetails_Select]
@CourseSemesterId int = null

AS
SELECT        Courses.Name, Members.FirstName, Members.LastName, CourseSemester.Lecture,CourseSemester.Time, CourseSemester.Id
FROM            Members INNER JOIN
              Doctor ON Members.Id = Doctor.MemberID INNER JOIN
              CourseSemester ON Doctor.ID = CourseSemester.DoctorId INNER JOIN
              Courses ON CourseSemester.CourseId = Courses.ID
WHERE        (CourseSemester.Id IS NULL OR CourseSemester.Id = @CourseSemesterId)